<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>模块管理</title>
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}"/>
    <link rel="bookmark" th:href="@{/img/favicon.ico}" type="image/x-icon"/>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
    <script type="text/javascript">
        function tipOpen(content,num,chagestate) {
            $(".tipright p").text(content);
            $("#tip").fadeIn(200);
            $("#mid").val(num);
            $("#chagestate").val(chagestate);
        }

        function tipClose() {
            $("#tip").fadeOut(200);

            var mid=$("#mid").val();
            var chagestate=$("#chagestate").val();
            location.href="/erp1/sys/modules/updatestate?id="+mid+"&chagestate="+chagestate;
        }

        function tipClose2() {
            $("#tip").fadeOut(200);
        }
    </script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li><a th:href="@{/sys/users/userall}">系统管理</a></li>
        <li><a th:href="@{/sys/modules/moduleList}">模块管理</a></li>
    </ul>
</div>
<div class="rightinfo">
    <form th:action="@{/sys/modules/moduleList}" method="post" id="moudleForm">
        <input type="hidden" name="pageno" value="1" id="pageno"/>
        <ul class="tools">
            <li><label>模块名称:</label>
                <input type="text" name="mname" th:value="${mname}"/>
            </li>
            <li><label>父模块:</label>
                <select name="pid">
                    <option value="0">请选择</option>
                    <option th:each="p:${session.pallmodules}"
                            th:selected="${p.moduleId==pid?'true':'false'}"
                            th:text="${p.moduleRname}" th:value="${p.moduleId}"></option>
                </select>
            </li>

            <li class="subBut" onclick="goPage(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="window.location.href='moduleAdd.html'"><img th:src="@{/images/t01.png}">添加</li>
            <li class="subBut" onclick="reset()"><img th:src="@{/images/t03.png}"/>重置</li>
        </ul>
    </form>
    <table class="tablelist">
        <thead>
        <tr>
            <th>序号</th>
            <th>模块名称</th>
            <th>父模块</th>
            <th>URL</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="m : ${mdInfo.list}">
            <td th:text="${m.moduleId}">1</td>
            <td th:text="${m.moduleRname}">系统管理</td>
            <td th:text="${m.parentModule!=null?m.parentModule.moduleRname:'无'}"></td>
            <td th:text="${m.moduleMurl}">#</td>
            <td th:text="${m.moduleState=='1'?'正常':'注销'}">正常</td>
            <td>
                <a th:href="@{'/sys/modules/goUpdate/'+${m.moduleId}}" class="tablelink">修改</a>
                <a th:href="@{'/sys/modules/details/'+${m.moduleId}}" class="tablelink">详情</a>
                <input type="hidden" id="chagestate"/>
                <input type="hidden" id="mid"/>
                <a href="javascript:void(0)" th:if="${m.moduleState.equals('1')}" class="tablelink" th:onclick="@{'tipOpen(\'是否确认禁用此条信息？\','+${m.moduleId}+',2)'}">禁用</a>
                <a href="javascript:void(0)" th:if="${m.moduleState.equals('2')}" class="tablelink" th:onclick="@{'tipOpen(\'是否确认启用此条信息？\','+${m.moduleId}+',1)'}">启用</a>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="pagin">
        <div class="message">共<i class="blue" th:text="${mdInfo.total}"></i>条记录，当前显示第&nbsp;<i class="blue"
                                                                                              th:text="${mdInfo.pageNum}">2&nbsp;</i>页
        </div>
        <ul class="paginList">
            <li class="paginItem">
                <a href="javascript:void(0);" th:onclick="goPage([[${mdInfo.isFirstPage?1:mdInfo.pageNum-1}]])">
                    <span th:class="${mdInfo.isFirstPage?'pagepre':'pagenxt roate'}"></span>
                </a>
            </li>
            <li th:class="${page==mdInfo.pageNum?'paginItem current':'paginItem'}"
                th:each="page : ${mdInfo.navigatepageNums}">
                <a href="javascript:;" th:text="${page}" th:onclick="goPage([[${page}]])">1</a>
            </li>
            <li class="paginItem">
                <a href="javascript:void(0);"
                   th:onclick="goPage([[${mdInfo.isLastPage?mdInfo.pages:mdInfo.pageNum+1}]])">
                    <span th:class="${mdInfo.isLastPage?'pagepre roate':'pagenxt'}"></span>
                </a>
            </li>
        </ul>
    </div>

    <!-- 提示框 -->
    <div id="tip" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
        <div class="tipinfo"><span><img src="../../images/ticon.png"/></span>
            <div class="tipright">
                <p></p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite></div>
        </div>
        <div class="tipbtn">
            <input name="" type="button" class="sure" value="确定" onclick="tipClose()"/>
            &nbsp;
            <input name="" type="button" class="cancel" value="取消" onclick="tipClose2()"/>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');

    function goPage(num) {
        //submit提交
        $("#pageno").val(num);
        $("#moudleForm").submit();
    }

    function reset() {
        $("input[name=mname]").val("");
        $("select[name=pid]>option:eq(0)").attr("selected","true");
    }
</script>
</body>
</html>
